package com.hmall.search.listen;

import com.hmall.common.client.item.client.ItemClient;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
@Slf4j
public class ListenHandler {

    @Autowired
    private RestHighLevelClient client;

    @Autowired
    private ItemClient itemClient;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("search.queue"),
            exchange = @Exchange(value = "search.direct", type = ExchangeTypes.DIRECT),
            key = {"startStop"}
    ))
    public void updateData(Map<String, Long> map) throws IOException {
        // TODO 完成ES数据同步;
    }
}
